1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module sourceview.Encoding; 26 27 private import glib.ListSG; 28 private import glib.Str; 29 private import glib.c.functions; 30 private import gobject.ObjectG; 31 private import linker.Loader; 32 private import sourceview.c.functions; 33 public import sourceview.c.types; 34 35 36 /** 37 * Character encoding. 38 * 39 * The #GtkSourceEncoding boxed type represents a character encoding. It is used 40 * for example by #GtkSourceFile. Note that the text in GTK widgets is always 41 * encoded in UTF-8. 42 */ 43 public class Encoding 44 { 45 /** the main Gtk struct */ 46 protected GtkSourceEncoding* gtkSourceEncoding; 47 protected bool ownedRef; 48 49 /** Get the main Gtk struct */ 50 public GtkSourceEncoding* getEncodingStruct(bool transferOwnership = false) 51 { 52 if (transferOwnership) 53 ownedRef = false; 54 return gtkSourceEncoding; 55 } 56 57 /** the main Gtk struct as a void* */ 58 protected void* getStruct() 59 { 60 return cast(void*)gtkSourceEncoding; 61 } 62 63 /** 64 * Sets our main struct and passes it to the parent class. 65 */ 66 public this (GtkSourceEncoding* gtkSourceEncoding, bool ownedRef = false) 67 { 68 this.gtkSourceEncoding = gtkSourceEncoding; 69 this.ownedRef = ownedRef; 70 } 71 72 ~this () 73 { 74 if ( Linker.isLoaded(LIBRARY_SOURCEVIEW[0]) && ownedRef ) 75 gtk_source_encoding_free(gtkSourceEncoding); 76 } 77 78 79 /** */ 80 public static GType getType() 81 { 82 return gtk_source_encoding_get_type(); 83 } 84 85 /** 86 * Used by language bindings. 87 * 88 * Returns: a copy of @enc. 89 */ 90 public Encoding copy() 91 { 92 auto __p = gtk_source_encoding_copy(gtkSourceEncoding); 93 94 if(__p is null) 95 { 96 return null; 97 } 98 99 return ObjectG.getDObject!(Encoding)(cast(GtkSourceEncoding*) __p, true); 100 } 101 102 /** 103 * Used by language bindings. 104 */ 105 public void free() 106 { 107 gtk_source_encoding_free(gtkSourceEncoding); 108 ownedRef = false; 109 } 110 111 /** 112 * Gets the character set of the #GtkSourceEncoding, such as "UTF-8" or 113 * "ISO-8859-1". 114 * 115 * Returns: the character set of the #GtkSourceEncoding. 116 */ 117 public string getCharset() 118 { 119 return Str.toString(gtk_source_encoding_get_charset(gtkSourceEncoding)); 120 } 121 122 /** 123 * Gets the name of the #GtkSourceEncoding such as "Unicode" or "Western". 124 * 125 * Returns: the name of the #GtkSourceEncoding. 126 */ 127 public string getName() 128 { 129 return Str.toString(gtk_source_encoding_get_name(gtkSourceEncoding)); 130 } 131 132 /** 133 * Returns: a string representation. Free with g_free() when no longer needed. 134 */ 135 public override string toString() 136 { 137 auto retStr = gtk_source_encoding_to_string(gtkSourceEncoding); 138 139 scope(exit) Str.freeString(retStr); 140 return Str.toString(retStr); 141 } 142 143 /** 144 * Gets all encodings. 145 * 146 * Returns: a list of 147 * all #GtkSourceEncoding's. Free with g_slist_free(). 148 */ 149 public static ListSG getAll() 150 { 151 auto __p = gtk_source_encoding_get_all(); 152 153 if(__p is null) 154 { 155 return null; 156 } 157 158 return new ListSG(cast(GSList*) __p); 159 } 160 161 /** 162 * Gets the #GtkSourceEncoding for the current locale. 163 * 164 * See also [func@GLib.get_charset]. 165 * 166 * Returns: the current locale encoding. 167 */ 168 public static Encoding getCurrent() 169 { 170 auto __p = gtk_source_encoding_get_current(); 171 172 if(__p is null) 173 { 174 return null; 175 } 176 177 return ObjectG.getDObject!(Encoding)(cast(GtkSourceEncoding*) __p); 178 } 179 180 /** 181 * Gets the list of default candidate encodings to try when loading a file. 182 * 183 * See [method@FileLoader.set_candidate_encodings]. 184 * 185 * This function returns a different list depending on the current locale (i.e. 186 * language, country and default encoding). The UTF-8 encoding and the current 187 * locale encoding are guaranteed to be present in the returned list. 188 * 189 * Returns: the list of 190 * default candidate encodings. Free with g_slist_free(). 191 */ 192 public static ListSG getDefaultCandidates() 193 { 194 auto __p = gtk_source_encoding_get_default_candidates(); 195 196 if(__p is null) 197 { 198 return null; 199 } 200 201 return new ListSG(cast(GSList*) __p); 202 } 203 204 /** 205 * Gets a #GtkSourceEncoding from a character set such as "UTF-8" or 206 * "ISO-8859-1". 207 * 208 * Params: 209 * charset = a character set. 210 * 211 * Returns: the corresponding #GtkSourceEncoding, or %NULL 212 * if not found. 213 */ 214 public static Encoding getFromCharset(string charset) 215 { 216 auto __p = gtk_source_encoding_get_from_charset(Str.toStringz(charset)); 217 218 if(__p is null) 219 { 220 return null; 221 } 222 223 return ObjectG.getDObject!(Encoding)(cast(GtkSourceEncoding*) __p); 224 } 225 226 /** 227 * Returns: the UTF-8 encoding. 228 */ 229 public static Encoding getUtf8() 230 { 231 auto __p = gtk_source_encoding_get_utf8(); 232 233 if(__p is null) 234 { 235 return null; 236 } 237 238 return ObjectG.getDObject!(Encoding)(cast(GtkSourceEncoding*) __p); 239 } 240 }